package com.easyui.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import net.sf.json.JSONObject;

import com.easyui.common.UserLogin;

public class QuitLoginServlet extends HttpServlet {

	public QuitLoginServlet() {}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/json;charset=utf-8");
		response.setCharacterEncoding("UTF-8");
		request.setCharacterEncoding("UTF-8");
		PrintWriter out = response.getWriter();
		
		JSONObject jsonAll = null;
		boolean success = false;
		String msg = "";
		
		HttpSession session = request.getSession(); //获的session
		session.removeAttribute("role");
		session.removeAttribute("userID");
		//response.sendRedirect("login_in.html");
		success = true;
		msg = "退出成功.";
		
		jsonAll = new JSONObject();
		jsonAll.put("success", success);
		jsonAll.put("msg", msg);
		
		out.print(jsonAll);
		out.flush();
		out.close();
	}

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException {
		doPost(request, response);
	}
}
